package ch.unisi.inf.pfii.teamred.pacman.model;

import java.util.HashMap;

/**
 * This class describes a command in the Pacman game.
 * 
 * @author luca.vignola@lu.unisi.ch
 * 
 */

public final class Command {

	private final HashMap<String, Direction> validDirections;

	public Command() {
		validDirections = new HashMap<String, Direction>();

		validDirections.put("up", Direction.UP);
		validDirections.put("down", Direction.DOWN);
		validDirections.put("right", Direction.RIGHT);
		validDirections.put("left", Direction.LEFT);
		validDirections.put("stop", Direction.STOP);
	}

	public final Direction getDirection(final String newDirection) {
		Direction direction = validDirections.get(newDirection);
		if (direction != null) {
			return direction;
		} else {
			return validDirections.get("stop");
		}
	}

}
